#!/usr/bin/env python
# coding: utf-8

# In[1]:


import random    # 随机策略时用到
import matplotlib.pyplot as plt
import numpy as np


# In[49]:


x = np.arange(0,20,0.2)
y_greedy = 0.4 * x
y_e_greedy = 0.3 * x
y_decay = 2 * np.log10(x+1)


# In[53]:


fig = plt.figure(figsize=(12,6))#subplots(nrows=1, ncols=2, figsize=(12,8))
#fig.suptitle(r'3D surface of $J(w_1,w_2)$ and gradient descent')
ax = fig.add_subplot(1,1,1)


ax.plot(x, y_greedy, color="green")
ax.plot(x, y_e_greedy, color = "red")
ax.plot(x, y_decay, color = "black")

ax.set_xlabel(xlabel='time-steps', fontsize=15)
ax.set_ylabel(ylabel='total reget', fontsize =15)
ax.set_title("")
plt.yticks([])

greedy = ax.text(7.2, 3.8, r'$greedy$', fontsize=15, color="green")
greedy = ax.text(12.5, 3.3, r'$\epsilon-greedy$', fontsize=15, color="red")
greedy = ax.text(12.5, 1.7, r'$decaying\ \epsilon-greedy$', fontsize=15)
plt.show()  


# In[56]:


def gaussian_density(x, mu = 0, sigma = 1 ):
    expo = -1 * np.power((x-mu),2)/(2*np.power(sigma,2))
    return np.power(np.e,expo)/(np.sqrt(2*np.pi)*sigma)


# In[104]:


x = np.arange(-1.98, 5.98, 0.04)
y = gaussian_density(x, mu=2.2, sigma = 0.3)
y1 = gaussian_density(x, mu=1.6, sigma = 0.8)
y2 = gaussian_density(x, mu=1.2, sigma = 2)


# In[120]:


fig = plt.figure(figsize=(12,6))#subplots(nrows=1, ncols=2, figsize=(12,8))
#fig.suptitle(r'3D surface of $J(w_1,w_2)$ and gradient descent')
ax = fig.add_subplot(1,1,1)
#ax.grid()

# 隐藏上边和右边
ax.spines['top'].set_color('none')
ax.spines['right'].set_color('none')
# 移动另外连个轴
ax.xaxis.set_ticks_position('bottom')
ax.spines['bottom'].set_position(('data', 0))
ax.yaxis.set_ticks_position('left')
ax.spines['left'].set_position(('data', 0))

plt.yticks([])
plt.xticks([-1,1,2,3,4,5])
ax.plot(x, y, color="green")
ax.plot(x, y1, color = "red")
ax.plot(x, y2, color = "blue")

ax.set_xlabel(xlabel='Q', fontsize=15)
ax.set_ylabel(ylabel='p(Q)', fontsize =15)
ax.set_title("")


qa1 = ax.text(0.1, 0.25, r'$Q(a_1)$', fontsize=15, color="blue")
qa2 = ax.text(1.2, 0.55, r'$Q(a_2)$', fontsize=15, color="red")
qa3 = ax.text(2.6, 0.8, r'$Q(a_3)$', fontsize=15, color="green")

plt.show()  


# In[ ]:





# In[ ]:





# In[ ]:




